package test0126;

public class TestTreeNode {

    static class TreeNode {
        int val;
        TreeNode leftNode;
        TreeNode rightNode;

        TreeNode(int val) {
            this.val = val;
        }
    }

    static void traverse(TreeNode treeNode) {
        if (treeNode == null) {
            return;
        }
        //
        traverse(treeNode.rightNode);
        //
        traverse(treeNode.leftNode);
        //
        System.err.println(treeNode.val);
    }

    /**
     * <P>       0
     * 1            2
     * 3     4      5       6
     * 7  8  9  10  11 12  13 14
     * </P>
     *
     * @param args
     */
    public static void main(String[] args) {
        TreeNode root = new TreeNode(0);
        TreeNode n1 = new TreeNode(1);
        TreeNode n2 = new TreeNode(2);
        TreeNode n3 = new TreeNode(3);
        TreeNode n4 = new TreeNode(4);
        TreeNode n5 = new TreeNode(5);
        TreeNode n6 = new TreeNode(6);
        TreeNode n7 = new TreeNode(7);
        TreeNode n8 = new TreeNode(8);
        TreeNode n9 = new TreeNode(9);
        TreeNode n10 = new TreeNode(10);
        TreeNode n11 = new TreeNode(11);
        TreeNode n12 = new TreeNode(12);
        TreeNode n13 = new TreeNode(13);
        TreeNode n14 = new TreeNode(14);
        root.leftNode = n1;
        root.rightNode = n2;
        n1.leftNode = n3;
        n1.rightNode = n4;
        n2.leftNode = n5;
        n2.rightNode = n6;
        n3.leftNode = n7;
        n3.rightNode = n8;
        n4.leftNode = n9;
        n4.rightNode = n10;
        n5.leftNode = n11;
        n5.rightNode = n12;
        n6.leftNode = n13;
        n6.rightNode = n14;
        traverse(root);
    }
}
